﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
//new
using MyRegester;
using System.IO;
using ZoomPicBox;
using JKZP.DAL;
using System.Text.RegularExpressions;
using JKZP.Helpers;
using JKZP.Model;
using System.Runtime.InteropServices;


namespace JKZP
{
    public partial class Form_Main : Form
    {
        Timer m_systemTimer;
        JKCamera m_CurrentCam;
        int speed = 4;
        int I = 0;//抓拍组序号
        const int cMaxSpeed = 8;
        const int cMinSpeed = 1;
        int[] index = new int[20];
        DateTime[] m_WFSJ = new DateTime[20];//违法时间，取第二张图片的时间
        string[] m_HPHM = new string[20];
        Point pointStart;
        Point pointEnd;
        bool m_FlagRect;
        aitmskdws.aitmskdws kdws = null;
        Font font = new Font("Arial", 25);
        int SplitterDistance1;
        int SplitterDistance2;

        System.Timers.Timer stt1 = new System.Timers.Timer();
        System.Timers.Timer stt2 = new System.Timers.Timer();
        System.Timers.Timer stt3 = new System.Timers.Timer();
        System.Timers.Timer stt4 = new System.Timers.Timer();
        System.Timers.Timer stt5 = new System.Timers.Timer();
        System.Timers.Timer stt6 = new System.Timers.Timer();
        System.Timers.Timer stt7 = new System.Timers.Timer();
        System.Timers.Timer stt8 = new System.Timers.Timer();
        System.Timers.Timer stt9 = new System.Timers.Timer();
        System.Timers.Timer stt10 = new System.Timers.Timer();

        public Form_Main()
        {
            InitializeComponent();
        }

        private void Form_Main_Load(object sender, EventArgs e)
        {
            try
            {

                //时间显示
                m_systemTimer = new Timer();
                m_systemTimer.Interval = 1000;
                m_systemTimer.Tick += new EventHandler(m_systemTimer_Tick);
                m_systemTimer.Start();


                index[0] = 0;
                index[1] = 0;
                index[2] = 0;
                index[3] = 0;
                index[4] = 0;


                for (int i = 0; i < 20; i++)
                {
                    m_WFSJ[i] = DateTime.Now;
                }

                //路口树
                UpDateTree();

                //初始化SDK
                PP.DHSDKInit();
                PP.HKSDKInit();

                //默认号牌号码显示
                textBox_hphm.Text = PP.gDefaultHPHM;
                for (int i = 0; i < 20; i++)
                {
                    m_HPHM[i] = PP.gDefaultHPHM;
                }
                //违法行为
                string[] wfxwdm = File.ReadAllLines(PP.gWFXWDMFile);
                if (wfxwdm != null)
                {
                    comboBox_wfxw.MouseWheel += new MouseEventHandler(comboBox_wfxw_MouseWheel);
                    comboBox_wfxw.Items.Clear();
                    comboBox_wfxw.Items.AddRange(wfxwdm);
                    comboBox_wfxw.SelectedIndex = 0;
                }

                string[] hpzl = File.ReadAllLines(PP.gHPZLFile);
                if (hpzl != null)
                {
                    comboBox_hpzl.MouseWheel += new MouseEventHandler(comboBox_hpzl_MouseWheel);
                    comboBox_hpzl.Items.Clear();
                    comboBox_hpzl.Items.AddRange(hpzl);
                    comboBox_hpzl.SelectedIndex = 1;
                }

                //检查注册
                RegMgr.m_LocalIP = PP.gLocalIP;
                RegMgr.m_RegNode = PP.gRegNode;
                PP.gSoftRegstor = RegMgr.SoftRegstered;
                SetSystemEnable(true, PP.gUser.admin);
                //SetSystemEnable(PP.gSoftRegstor, PP.gUser.admin);


                //3D
                pointStart = new Point(0, 0);
                pointEnd = new Point(0, 0);
                m_FlagRect = false;

                this.zoomPictureBox_1_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_1_1_DoubleClick);
                this.zoomPictureBox_1_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_1_2_DoubleClick);
                this.zoomPictureBox_1_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_1_3_DoubleClick);

                this.zoomPictureBox_2_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_2_1_DoubleClick);
                this.zoomPictureBox_2_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_2_2_DoubleClick);
                this.zoomPictureBox_2_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_2_3_DoubleClick);

                this.zoomPictureBox_3_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_3_1_DoubleClick);
                this.zoomPictureBox_3_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_3_2_DoubleClick);
                this.zoomPictureBox_3_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_3_3_DoubleClick);

                this.zoomPictureBox_4_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_4_1_DoubleClick);
                this.zoomPictureBox_4_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_4_2_DoubleClick);
                this.zoomPictureBox_4_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_4_3_DoubleClick);

                this.zoomPictureBox_5_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_5_1_DoubleClick);
                this.zoomPictureBox_5_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_5_2_DoubleClick);
                this.zoomPictureBox_5_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_5_3_DoubleClick);

                this.zoomPictureBox_6_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_6_1_DoubleClick);
                this.zoomPictureBox_6_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_6_2_DoubleClick);
                this.zoomPictureBox_6_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_6_3_DoubleClick);

                this.zoomPictureBox_7_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_7_1_DoubleClick);
                this.zoomPictureBox_7_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_7_2_DoubleClick);
                this.zoomPictureBox_7_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_7_3_DoubleClick);

                this.zoomPictureBox_8_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_8_1_DoubleClick);
                this.zoomPictureBox_8_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_8_2_DoubleClick);
                this.zoomPictureBox_8_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_8_3_DoubleClick);

                this.zoomPictureBox_9_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_9_1_DoubleClick);
                this.zoomPictureBox_9_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_9_2_DoubleClick);
                this.zoomPictureBox_9_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_9_3_DoubleClick);

                this.zoomPictureBox_10_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_10_1_DoubleClick);
                this.zoomPictureBox_10_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_10_2_DoubleClick);
                this.zoomPictureBox_10_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_10_3_DoubleClick);

                this.zoomPictureBox_11_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_11_1_DoubleClick);
                this.zoomPictureBox_11_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_11_2_DoubleClick);
                this.zoomPictureBox_11_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_11_3_DoubleClick);
                this.zoomPictureBox_12_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_12_1_DoubleClick);
                this.zoomPictureBox_12_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_12_2_DoubleClick);
                this.zoomPictureBox_12_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_12_3_DoubleClick);
                this.zoomPictureBox_13_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_13_1_DoubleClick);
                this.zoomPictureBox_13_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_13_2_DoubleClick);
                this.zoomPictureBox_13_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_13_3_DoubleClick);
                this.zoomPictureBox_14_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_14_1_DoubleClick);
                this.zoomPictureBox_14_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_14_2_DoubleClick);
                this.zoomPictureBox_14_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_14_3_DoubleClick);
                this.zoomPictureBox_15_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_15_1_DoubleClick);
                this.zoomPictureBox_15_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_15_2_DoubleClick);
                this.zoomPictureBox_15_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_15_3_DoubleClick);
                this.zoomPictureBox_16_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_16_1_DoubleClick);
                this.zoomPictureBox_16_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_16_2_DoubleClick);
                this.zoomPictureBox_16_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_16_3_DoubleClick);

                this.zoomPictureBox_17_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_17_1_DoubleClick);
                this.zoomPictureBox_17_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_17_2_DoubleClick);
                this.zoomPictureBox_17_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_17_3_DoubleClick);

                this.zoomPictureBox_18_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_18_1_DoubleClick);
                this.zoomPictureBox_18_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_18_2_DoubleClick);
                this.zoomPictureBox_18_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_18_3_DoubleClick);

                this.zoomPictureBox_19_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_19_1_DoubleClick);
                this.zoomPictureBox_19_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_19_2_DoubleClick);
                this.zoomPictureBox_19_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_19_3_DoubleClick);

                this.zoomPictureBox_20_1.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_20_1_DoubleClick);
                this.zoomPictureBox_20_2.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_20_2_DoubleClick);
                this.zoomPictureBox_20_3.pictureBox1.DoubleClick += new EventHandler(zoomPictureBox_20_3_DoubleClick);







                SplitterDistance1 = 10;
                SplitterDistance2 = this.splitContainer1.SplitterDistance;

                if (PP.gISWebVersion == true)
                {
                    kdws = new JKZP.aitmskdws.aitmskdws();
                }
            }
            catch { }
        }

        void comboBox_hpzl_MouseWheel(object sender, MouseEventArgs e)
        {
            try
            {
                if (e.Delta < 0)
                {
                    if (comboBox_hpzl.SelectedIndex < comboBox_hpzl.Items.Count - 1)
                    {
                        comboBox_hpzl.SelectedIndex++;
                    }
                }
                else if (e.Delta > 0)
                {
                    if (comboBox_hpzl.SelectedIndex > 0)
                    {
                        comboBox_hpzl.SelectedIndex--;
                    }
                }

            }
            catch { ;}
        }

        void comboBox_wfxw_MouseWheel(object sender, MouseEventArgs e)
        {
            try
            {
                
                if (e.Delta<0)
                {
                    if (comboBox_wfxw.SelectedIndex < comboBox_wfxw.Items.Count - 1)
                    {
                        comboBox_wfxw.SelectedIndex++;
                    }
                }
                else if (e.Delta > 0)
                {
                    if (comboBox_wfxw.SelectedIndex > 0)
                    {
                        comboBox_wfxw.SelectedIndex--;
                    }
                }

            }
            catch { ;}
        }

        public void UpDateTree()
        {
            treeView1.Nodes.Clear();
            TreeNode root = new TreeNode();
            root.Text = "杰瑞监控抓拍系统";
            root.Tag = "root";
            root.Name = "root";
            root.ImageIndex = 0;
            root.SelectedImageIndex = 0;
            treeView1.Nodes.Add(root);
            if (PP.gRoadList != null)
            {
                foreach (PP.RoadParam road in PP.gRoadList)
                {
                    TreeNode roadnode = new TreeNode();
                    roadnode.Text = road.LKMC;
                    roadnode.Tag = road.LKID;
                    roadnode.Name = "road";
                    roadnode.ImageIndex = 1;
                    roadnode.SelectedImageIndex = 1;
                    root.Nodes.Add(roadnode);
                    if (road.JKCamList != null)
                    {
                        foreach (JKCamera cam in road.JKCamList)
                        {
                            TreeNode camnode = new TreeNode();
                            camnode.Text = cam.m_IP + "---" + cam.m_CameraName + "---" + cam.m_Type;
                            camnode.Tag = cam.m_IP;
                            camnode.Name = "camera";
                            camnode.SelectedImageIndex = 2;
                            camnode.ImageIndex = 2;
                            roadnode.Nodes.Add(camnode);
                        }
                    }
                }
            }
            treeView1.ExpandAll();
        }

        public void UpdateCombobox()
        {
            try
            {
                //违法行为
                string[] wfxwdm = File.ReadAllLines(PP.gWFXWDMFile);
                if (wfxwdm != null)
                {
                    comboBox_wfxw.Items.Clear();
                    comboBox_wfxw.Items.AddRange(wfxwdm);
                    comboBox_wfxw.SelectedIndex = 0;
                }

                string[] hpzl = File.ReadAllLines(PP.gHPZLFile);
                if (hpzl != null)
                {
                    comboBox_hpzl.Items.Clear();
                    comboBox_hpzl.Items.AddRange(hpzl);
                    comboBox_hpzl.SelectedIndex = 1;
                }
            }
            catch { }
        }

        public void SetSystemEnable(bool regstor, bool admin)
        {
            

            this.toolStripMenuItem_user.Enabled = regstor;
            this.toolStripMenuItem_yhgl.Enabled = regstor;
            this.toolStripMenuItem_changepassword.Enabled = regstor;
            this.toolStripMenuItem_param.Enabled = regstor;
            this.toolStripMenuItem_sys.Enabled = regstor;
            this.toolStripMenuItem_road.Enabled = regstor;
            this.toolStripMenuItem_camera.Enabled = regstor;
            this.toolStripMenuItem_wfxwdm.Enabled = regstor;
            this.ToolStripMenuItem_hpzl.Enabled = regstor;
            this.ToolStripMenuItem_upload.Enabled = regstor;
            this.toolStripMenuItem_tongji.Enabled = regstor;
            this.ToolStripMenuItem_virsion.Enabled = regstor;
            this.splitContainer1.Enabled = regstor;

            if (PP.gISWebVersion == false)
            {
                this.toolStripMenuItem_yhgl.Visible = false;
                this.ToolStripMenuItem_tongji2.Visible = false;
            }
            else
            { 
                this.toolStripMenuItem_yhgl.Visible = admin;
                this.ToolStripMenuItem_tongji2.Visible = true;
            }
            this.toolStripMenuItem_param.Visible = admin;
            this.toolStripMenuItem_sys.Visible = admin;
            this.toolStripMenuItem_road.Visible = admin;
            this.toolStripMenuItem_camera.Visible = admin;
            this.toolStripMenuItem_wfxwdm.Visible = admin;
            this.ToolStripMenuItem_hpzl.Visible = admin;
            
            this.toolStripStatusLabel_state.Text = (regstor ? "软件已注册" : "软件未注册");

        }

        void m_systemTimer_Tick(object sender, EventArgs e)
        {
            this.toolStripStatusLabel_time.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        }

        private void Form_Main_FormClosed(object sender, FormClosedEventArgs e)
        {
            MyClose();
        }

        private void MyClose()
        {
            try
            {
                //关时间显示
                if (m_systemTimer != null)
                {
                    m_systemTimer.Stop();
                    m_systemTimer.Dispose();
                }

                if (PP.kdws != null) PP.kdws.Dispose();

                if (m_CurrentCam != null)
                {
                    if(m_CurrentCam!=null)m_CurrentCam.ShutDown();
                }

                //SDK回收资源
                PP.HKSDKDispose();
                PP.DHSDKDispose();
            }
            catch { }
        }

        //系统参数
        private void toolStripMenuItem_sys_Click(object sender, EventArgs e)
        {
            SysParamForm form = new SysParamForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        //路口参数
        private void ToolStripMenuItem_road_Click(object sender, EventArgs e)
        {
            RoadForm form = new RoadForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        //摄像机参数
        private void ToolStripMenuItem_camera_Click(object sender, EventArgs e)
        {
            CameraForm form = new CameraForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void toolStripMenuItem_ip_Click(object sender, EventArgs e)
        {
            LocalIPForm form = new LocalIPForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        //软件注册
        private void toolStripMenuItem_reg_Click(object sender, EventArgs e)
        {
            RegForm form_reg = new RegForm();
            form_reg.Owner = this;
            form_reg.ShowDialog();
            form_reg.Dispose();
            SetSystemEnable(true, PP.gUser.admin);
            //SetSystemEnable(PP.gSoftRegstor,PP.gUser.admin);
        }

        //版本说明
        private void ToolStripMenuItem_virsion_Click(object sender, EventArgs e)
        {
            virsion form_virsion = new virsion();
            form_virsion.Owner = this;
            form_virsion.ShowDialog();
            form_virsion.Dispose();
        }

        //退出
        private void ToolStripMenuItem_exit_Click(object sender, EventArgs e)
        {
            Close();
        }

        //保存预置点
        private void toolStripMenuItem_Set_Click(object sender, EventArgs e)
        {
            if (toolStripTextBox_name.Text == "")
            {
                this.toolStripStatusLabel_state.Text = "保存预置点失败，助记名为空";
                return;
            }
            if (m_CurrentCam == null)
            {
                this.toolStripStatusLabel_state.Text = "保存预置点失败，摄像机未启动";
                return;
            }

            int index = this.listBox_PreSetPoint.SelectedIndex;
            if (index > -1)
            {
                if (m_CurrentCam.SavePreSetPoint(index + 1) == true)
                {
                    string xpath = "descendant::camera[@ip='" + m_CurrentCam.m_IP + "']/PreSetPoint[@index='" + index.ToString() + "']";
                    if (PP.SetConfig(PP.gRoadFile, xpath, this.toolStripTextBox_name.Text, null, null) == true)
                    {
                        m_CurrentCam.m_PreSetPonitHelpName[index] = this.toolStripTextBox_name.Text;
                        this.listBox_PreSetPoint.Items.RemoveAt(index);
                        this.listBox_PreSetPoint.Items.Insert(index, (index + 1).ToString() + "---" + this.toolStripTextBox_name.Text);
                        if (PP.gISWebVersion == false)
                        {
                            this.toolStripStatusLabel_state.Text = "保存预置点成功";
                        }
                        else
                        {
                            if (PP.kdws.JKZP_EditYZD(m_CurrentCam.m_IP, index.ToString(), this.toolStripTextBox_name.Text) == true)
                            {
                                this.toolStripStatusLabel_state.Text = "保存预置点成功";
                            }
                            else
                            {
                                this.toolStripStatusLabel_state.Text = "保存预置点失败";
                            }
                        }
                    }
                }
            }
        }
    

        private void contextMenuStrip1_VisibleChanged(object sender, EventArgs e)
        {
            if (contextMenuStrip1.Visible)
            {
                toolStripTextBox_name.Text = "";
            }
        }

        private void treeView1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (treeView1.SelectedNode == null) return;
                if (treeView1.SelectedNode.Name != "camera") return;
                if(I>19)return;
                if(I<0)return;
                string camip = treeView1.SelectedNode.Tag.ToString();



                if ((m_CurrentCam != null) && (camip == m_CurrentCam.m_IP) && (m_CurrentCam.m_CamIsOpen)) return;
                
                if (m_CurrentCam != null)
                {
                    m_CurrentCam.ShutDown();
                    this.panel_play.Invalidate();
                }
                m_CurrentCam = PP.FindCamByIP(camip);
                if (m_CurrentCam != null)
                {
                    m_CurrentCam.Play(panel_play.Handle);
                    this.listBox_PreSetPoint.Items.Clear();
                    if ((m_CurrentCam.m_PreSetPonitHelpName != null) && (m_CurrentCam.m_PreSetPonitHelpName.Count > 0))
                    {
                        for (int i = 0; i < m_CurrentCam.m_PreSetPonitHelpName.Count; i++)
                        {
                            this.listBox_PreSetPoint.Items.Add((i + 1).ToString() + "---" + m_CurrentCam.m_PreSetPonitHelpName[i]);
                        }
                    }
                    m_CurrentCam.CheckTime();
                }
            }
            catch (System.Exception ex)
            {  
                  
                  
            }

        }

        private void button_speeddown_Click(object sender, EventArgs e)
        {
            if (speed > cMinSpeed) speed--;
            this.toolStripStatusLabel_state.Text = "球机速度 = " + speed.ToString();
        }

        private void button_speedup_Click(object sender, EventArgs e)
        {
            if (speed < cMaxSpeed) speed++;
            this.toolStripStatusLabel_state.Text = "球机速度 = " + speed.ToString();
        }

        private void button_center_Click(object sender, EventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.CallPreSetPoint(1);
        }

        private void button_up_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Up(speed, false);
        }

        private void button_up_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Up(speed, true);
        }

        private void button_down_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Down(speed, false);
        }

        private void button_down_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Down(speed, true);
        }

        private void button_left_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Left(speed, false);
        }

        private void button_left_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Left(speed, true);
        }

        private void button_right_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Right(speed, false);
        }

        private void button_right_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Right(speed, true);
        }

        private void button_near_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.ZoomIn(speed, false);
        }

        private void button_near_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.ZoomIn(speed, true);
        }

        private void button_far_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.ZoomOut(speed, false);
        }

        private void button_far_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Down(speed, true);
        }

        //调用预置点
        private void listBox_PreSetPoint_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (this.listBox_PreSetPoint.SelectedIndex > -1)
            {
                if (m_CurrentCam != null) m_CurrentCam.CallPreSetPoint(this.listBox_PreSetPoint.SelectedIndex + 1);
            }
        }

        [DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
        private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);


        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
        public const int WM_CLOSE = 0x10;

        private void StartKiller(int getTime)
        {
            Timer SetTimer = new Timer();         // 宣告一個Timer物件，名稱為 SetTimer 
            SetTimer.Interval = (getTime * 1000);          //x秒后启动
            SetTimer.Tick += new EventHandler(SetTimer_Tick);   // 建立一个触发Tick事件 
            SetTimer.Start();                     // 启动Timer (即SetTimer 开始启动 ) 
        }

        void SetTimer_Tick(object sender, EventArgs e)
        {
            KillMessageBox();         // 執行把 MessageBox 刪除 (即让MessageBox消失) 
            ((Timer)sender).Stop();    //停止時間。記得要转型为 Timer 型別 
        }

        private void KillMessageBox()
        {
            // 按照MessageBox的标题，找出Messagebox这个视窗  
            IntPtr ptr = FindWindow(null, "Title!");
            if (ptr != IntPtr.Zero)    // 此表示只要 ptr 不为空值的内容时 
            {
                //找到则关闭 MessageBox 視窗  
                PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
            }
        }

        private void button_capture_Click(object sender, EventArgs e)
        {
            try
            {
                if ((I < 0) || (I > 20)) return;
                if (m_CurrentCam != null)
                {

                    if (index[I] == 3)
                    {
                        return;//index[I] = 0;

                    }
                    index[I]++;
                    DateTime time = DateTime.Now.Subtract(new TimeSpan(0,0,0,1));//设备显示的叠加时间比获取到的时间少1秒
                    if (index[I] == 1)
                    {
                        m_WFSJ[I] = time;//张家界从第二张获取违法时间，连云港从第一张获取时间
                        //if (index == 1) m_CurrentCam.m_WFSJ = m_CurrentCam.GetDeviceTime();//从设备获取时间
                        this.dateTimePicker1.Value = time;


                        switch (I)
                        {
                            case 0:
                                stt1.Enabled = true;
                                stt1.Start();
                                stt1.AutoReset = false; //每到指定时间Elapsed事件是触发一次（false），还是一直触发（true）
                                stt1.Interval = 300000;
                                stt1.Elapsed += new System.Timers.ElapsedEventHandler(stt1_Elapsed);
                                break;
                            case 1:
                                stt2.Enabled = true;
                                stt2.Start();
                                stt2.AutoReset = false; //每到指定时间Elapsed事件是触发一次（false），还是一直触发（true）
                                stt2.Interval = 300000; 
                                stt2.Elapsed += new System.Timers.ElapsedEventHandler(stt2_Elapsed);
                                break;
                            case 2:
                                stt3.Enabled = true;
                                stt3.Start();
                                stt3.AutoReset = false;
                                stt3.Interval = 300000;
                                stt3.Elapsed += new System.Timers.ElapsedEventHandler(stt3_Elapsed);
                                break;
                            case 3:
                                stt4.Enabled = true;
                                stt4.Start();
                                stt4.AutoReset = false;
                                stt4.Interval = 300000;
                                stt4.Elapsed += new System.Timers.ElapsedEventHandler(stt4_Elapsed);
                                break;
                            case 4:
                                stt5.Enabled = true;
                                stt5.Start();
                                stt5.AutoReset = false;
                                stt5.Interval = 300000;
                                stt5.Elapsed += new System.Timers.ElapsedEventHandler(stt5_Elapsed);
                                break;
                            case 5:
                                stt6.Enabled = true;
                                stt6.Start();
                                stt6.AutoReset = false;
                                stt6.Interval = 300000;
                                stt6.Elapsed += new System.Timers.ElapsedEventHandler(stt6_Elapsed);
                                break;
                            case 6:
                                stt7.Enabled = true;
                                stt7.Start();
                                stt7.AutoReset = false;
                                stt7.Interval = 300000;
                                stt7.Elapsed += new System.Timers.ElapsedEventHandler(stt7_Elapsed);
                                break;
                            case 7:
                                stt8.Enabled = true;
                                stt8.Start();
                                stt8.AutoReset = false;
                                stt8.Interval = 300000;
                                stt8.Elapsed += new System.Timers.ElapsedEventHandler(stt8_Elapsed);
                                break;
                            case 8:
                                stt9.Enabled = true;
                                stt9.Start();
                                stt9.AutoReset = false;
                                stt9.Interval = 300000;
                                stt9.Elapsed += new System.Timers.ElapsedEventHandler(stt9_Elapsed);
                                break;
                            case 9:
                                stt10.Enabled = true;
                                stt10.Start();
                                stt10.AutoReset = false;
                                stt10.Interval = 300000;
                                stt10.Elapsed += new System.Timers.ElapsedEventHandler(stt10_Elapsed);
                                break;


                        }

                        m_HPHM[I] = textBox_hphm.Text;
                    }
                    if (m_CurrentCam.CaptureOnePic((I + 1).ToString(), index[I].ToString()) == true)
                    {
                        if (File.Exists(m_CurrentCam.m_TempPicName))
                        {
                            Control[] cc = this.Controls.Find("zoomPictureBox_" + (I + 1).ToString() + "_" + index[I].ToString(), true);
                            if ((cc != null) && (cc.Length > 0))
                            {
                                ZoomPictureBox box = (cc[0] as ZoomPictureBox);
                                box.time = time.ToString();
                                box.pictureBox1.LoadAsync(m_CurrentCam.m_TempPicName);
                            }
                        }
                    }
                }
            }
            catch { }
        }

        private void stt1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show(" 抓拍组一到5分钟！", "Title!"); 
            stt1.Stop();
        }
        private void stt2_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组二到5分钟", "Title!");
            stt2.Stop();

        }
        private void stt3_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组三到5分钟", "Title!");
            stt3.Stop();
        }
        private void stt4_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组四到5分钟", "Title!");
            stt4.Stop();
        }
        private void stt5_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组五到5分钟", "Title!");
            stt5.Stop();
        }
        private void stt6_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组六到5分钟", "Title!");
            stt6.Stop();
        }
        private void stt7_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组七到5分钟", "Title!");
            stt7.Stop();
        }
        private void stt8_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组八到5分钟", "Title!");
            stt8.Stop();
        }
        private void stt9_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组九到5分钟", "Title!");
            stt9.Stop();
        }
        private void stt10_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            StartKiller(2);
            MessageBox.Show("抓拍组十到5分钟", "Title!");
            stt10.Stop();
        }

        private void button_clear_Click(object sender, EventArgs e)
        {

            try
            {
                if ((I < 0) || (I > 20)) return;

                if (I == 0)
                {
                    index[0] = 0;
                    zoomPictureBox_1_1.zoomRequired = false;
                    zoomPictureBox_1_1.pictureBox1.Image = null;
                    zoomPictureBox_1_2.zoomRequired = false;
                    zoomPictureBox_1_2.pictureBox1.Image = null;
                    zoomPictureBox_1_3.zoomRequired = false;
                    zoomPictureBox_1_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "1_1.jpg");
                    File.Delete(PP.gTempFolder + "1_2.jpg");
                    File.Delete(PP.gTempFolder + "1_3.jpg");
                    File.Delete(PP.gTempFolder + "1_1.bmp");
                    File.Delete(PP.gTempFolder + "1_2.bmp");
                    File.Delete(PP.gTempFolder + "1_3.bmp");
                }

                if (I == 1)
                {
                    index[1] = 0;
                    zoomPictureBox_2_1.zoomRequired = false;
                    zoomPictureBox_2_1.pictureBox1.Image = null;
                    zoomPictureBox_2_2.zoomRequired = false;
                    zoomPictureBox_2_2.pictureBox1.Image = null;
                    zoomPictureBox_2_3.zoomRequired = false;
                    zoomPictureBox_2_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "2_1.jpg");
                    File.Delete(PP.gTempFolder + "2_2.jpg");
                    File.Delete(PP.gTempFolder + "2_3.jpg");
                    File.Delete(PP.gTempFolder + "2_1.bmp");
                    File.Delete(PP.gTempFolder + "2_2.bmp");
                    File.Delete(PP.gTempFolder + "2_3.bmp");
                }

                if (I == 2)
                {
                    index[2] = 0;
                    zoomPictureBox_3_1.zoomRequired = false;
                    zoomPictureBox_3_1.pictureBox1.Image = null;
                    zoomPictureBox_3_2.zoomRequired = false;
                    zoomPictureBox_3_2.pictureBox1.Image = null;
                    zoomPictureBox_3_3.zoomRequired = false;
                    zoomPictureBox_3_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "3_1.jpg");
                    File.Delete(PP.gTempFolder + "3_2.jpg");
                    File.Delete(PP.gTempFolder + "3_3.jpg");
                    File.Delete(PP.gTempFolder + "3_1.bmp");
                    File.Delete(PP.gTempFolder + "3_2.bmp");
                    File.Delete(PP.gTempFolder + "3_3.bmp");
                }

                if (I == 3)
                {
                    index[3] = 0;
                    zoomPictureBox_4_1.zoomRequired = false;
                    zoomPictureBox_4_1.pictureBox1.Image = null;
                    zoomPictureBox_4_2.zoomRequired = false;
                    zoomPictureBox_4_2.pictureBox1.Image = null;
                    zoomPictureBox_4_3.zoomRequired = false;
                    zoomPictureBox_4_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "4_1.jpg");
                    File.Delete(PP.gTempFolder + "4_2.jpg");
                    File.Delete(PP.gTempFolder + "4_3.jpg");
                    File.Delete(PP.gTempFolder + "4_1.bmp");
                    File.Delete(PP.gTempFolder + "4_2.bmp");
                    File.Delete(PP.gTempFolder + "4_3.bmp");
                }

                if (I == 4)
                {
                    index[4] = 0;
                    zoomPictureBox_5_1.zoomRequired = false;
                    zoomPictureBox_5_1.pictureBox1.Image = null;
                    zoomPictureBox_5_2.zoomRequired = false;
                    zoomPictureBox_5_2.pictureBox1.Image = null;
                    zoomPictureBox_5_3.zoomRequired = false;
                    zoomPictureBox_5_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "5_1.jpg");
                    File.Delete(PP.gTempFolder + "5_2.jpg");
                    File.Delete(PP.gTempFolder + "5_3.jpg");
                    File.Delete(PP.gTempFolder + "5_1.bmp");
                    File.Delete(PP.gTempFolder + "5_2.bmp");
                    File.Delete(PP.gTempFolder + "5_3.bmp");
                }

                if (I == 5)
                {
                    index[5] = 0;
                    zoomPictureBox_6_1.zoomRequired = false;
                    zoomPictureBox_6_1.pictureBox1.Image = null;
                    zoomPictureBox_6_2.zoomRequired = false;
                    zoomPictureBox_6_2.pictureBox1.Image = null;
                    zoomPictureBox_6_3.zoomRequired = false;
                    zoomPictureBox_6_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "6_1.jpg");
                    File.Delete(PP.gTempFolder + "6_2.jpg");
                    File.Delete(PP.gTempFolder + "6_3.jpg");
                    File.Delete(PP.gTempFolder + "6_1.bmp");
                    File.Delete(PP.gTempFolder + "6_2.bmp");
                    File.Delete(PP.gTempFolder + "6_3.bmp");
                }

                if (I == 6)
                {
                    index[6] = 0;
                    zoomPictureBox_7_1.zoomRequired = false;
                    zoomPictureBox_7_1.pictureBox1.Image = null;
                    zoomPictureBox_7_2.zoomRequired = false;
                    zoomPictureBox_7_2.pictureBox1.Image = null;
                    zoomPictureBox_7_3.zoomRequired = false;
                    zoomPictureBox_7_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "7_1.jpg");
                    File.Delete(PP.gTempFolder + "7_2.jpg");
                    File.Delete(PP.gTempFolder + "7_3.jpg");
                    File.Delete(PP.gTempFolder + "7_1.bmp");
                    File.Delete(PP.gTempFolder + "7_2.bmp");
                    File.Delete(PP.gTempFolder + "7_3.bmp");
                }
                if (I == 7)
                {
                    index[7] = 0;
                    zoomPictureBox_8_1.zoomRequired = false;
                    zoomPictureBox_8_1.pictureBox1.Image = null;
                    zoomPictureBox_8_2.zoomRequired = false;
                    zoomPictureBox_8_2.pictureBox1.Image = null;
                    zoomPictureBox_8_3.zoomRequired = false;
                    zoomPictureBox_8_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "8_1.jpg");
                    File.Delete(PP.gTempFolder + "8_2.jpg");
                    File.Delete(PP.gTempFolder + "8_3.jpg");
                    File.Delete(PP.gTempFolder + "8_1.bmp");
                    File.Delete(PP.gTempFolder + "8_2.bmp");
                    File.Delete(PP.gTempFolder + "8_3.bmp");
                }
                if (I == 8)
                {
                    index[8] = 0;
                    zoomPictureBox_9_1.zoomRequired = false;
                    zoomPictureBox_9_1.pictureBox1.Image = null;
                    zoomPictureBox_9_2.zoomRequired = false;
                    zoomPictureBox_9_2.pictureBox1.Image = null;
                    zoomPictureBox_9_3.zoomRequired = false;
                    zoomPictureBox_9_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "9_1.jpg");
                    File.Delete(PP.gTempFolder + "9_2.jpg");
                    File.Delete(PP.gTempFolder + "9_3.jpg");
                    File.Delete(PP.gTempFolder + "9_1.bmp");
                    File.Delete(PP.gTempFolder + "9_2.bmp");
                    File.Delete(PP.gTempFolder + "9_3.bmp");
                }

                if (I == 9)
                {
                    index[9] = 0;
                    zoomPictureBox_10_1.zoomRequired = false;
                    zoomPictureBox_10_1.pictureBox1.Image = null;
                    zoomPictureBox_10_2.zoomRequired = false;
                    zoomPictureBox_10_2.pictureBox1.Image = null;
                    zoomPictureBox_10_3.zoomRequired = false;
                    zoomPictureBox_10_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "10_1.jpg");
                    File.Delete(PP.gTempFolder + "10_2.jpg");
                    File.Delete(PP.gTempFolder + "10_3.jpg");
                    File.Delete(PP.gTempFolder + "10_1.bmp");
                    File.Delete(PP.gTempFolder + "10_2.bmp");
                    File.Delete(PP.gTempFolder + "10_3.bmp");
                }

                if (I == 10)
                {
                    index[10] = 0;
                    zoomPictureBox_11_1.zoomRequired = false;
                    zoomPictureBox_11_1.pictureBox1.Image = null;
                    zoomPictureBox_11_2.zoomRequired = false;
                    zoomPictureBox_11_2.pictureBox1.Image = null;
                    zoomPictureBox_11_3.zoomRequired = false;
                    zoomPictureBox_11_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "11_1.jpg");
                    File.Delete(PP.gTempFolder + "11_2.jpg");
                    File.Delete(PP.gTempFolder + "11_3.jpg");
                    File.Delete(PP.gTempFolder + "11_1.bmp");
                    File.Delete(PP.gTempFolder + "11_2.bmp");
                    File.Delete(PP.gTempFolder + "11_3.bmp");
                }

                if (I == 11)
                {
                    index[11] = 0;
                    zoomPictureBox_12_1.zoomRequired = false;
                    zoomPictureBox_12_1.pictureBox1.Image = null;
                    zoomPictureBox_12_2.zoomRequired = false;
                    zoomPictureBox_12_2.pictureBox1.Image = null;
                    zoomPictureBox_12_3.zoomRequired = false;
                    zoomPictureBox_12_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "12_1.jpg");
                    File.Delete(PP.gTempFolder + "12_2.jpg");
                    File.Delete(PP.gTempFolder + "12_3.jpg");
                    File.Delete(PP.gTempFolder + "12_1.bmp");
                    File.Delete(PP.gTempFolder + "12_2.bmp");
                    File.Delete(PP.gTempFolder + "12_3.bmp");
                }
                if (I == 12)
                {
                    index[12] = 0;
                    zoomPictureBox_13_1.zoomRequired = false;
                    zoomPictureBox_13_1.pictureBox1.Image = null;
                    zoomPictureBox_13_2.zoomRequired = false;
                    zoomPictureBox_13_2.pictureBox1.Image = null;
                    zoomPictureBox_13_3.zoomRequired = false;
                    zoomPictureBox_13_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "13_1.jpg");
                    File.Delete(PP.gTempFolder + "13_2.jpg");
                    File.Delete(PP.gTempFolder + "13_3.jpg");
                    File.Delete(PP.gTempFolder + "13_1.bmp");
                    File.Delete(PP.gTempFolder + "13_2.bmp");
                    File.Delete(PP.gTempFolder + "13_3.bmp");
                }
                if (I == 13)
                {
                    index[13] = 0;
                    zoomPictureBox_14_1.zoomRequired = false;
                    zoomPictureBox_14_1.pictureBox1.Image = null;
                    zoomPictureBox_14_2.zoomRequired = false;
                    zoomPictureBox_14_2.pictureBox1.Image = null;
                    zoomPictureBox_14_3.zoomRequired = false;
                    zoomPictureBox_14_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "14_1.jpg");
                    File.Delete(PP.gTempFolder + "14_2.jpg");
                    File.Delete(PP.gTempFolder + "14_3.jpg");
                    File.Delete(PP.gTempFolder + "14_1.bmp");
                    File.Delete(PP.gTempFolder + "14_2.bmp");
                    File.Delete(PP.gTempFolder + "14_3.bmp");
                }
                if (I == 14)
                {
                    index[14] = 0;
                    zoomPictureBox_15_1.zoomRequired = false;
                    zoomPictureBox_15_1.pictureBox1.Image = null;
                    zoomPictureBox_15_2.zoomRequired = false;
                    zoomPictureBox_15_2.pictureBox1.Image = null;
                    zoomPictureBox_15_3.zoomRequired = false;
                    zoomPictureBox_15_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "15_1.jpg");
                    File.Delete(PP.gTempFolder + "15_2.jpg");
                    File.Delete(PP.gTempFolder + "15_3.jpg");
                    File.Delete(PP.gTempFolder + "15_1.bmp");
                    File.Delete(PP.gTempFolder + "15_2.bmp");
                    File.Delete(PP.gTempFolder + "15_3.bmp");
                }
                if (I == 15)
                {
                    index[15] = 0;
                    zoomPictureBox_16_1.zoomRequired = false;
                    zoomPictureBox_16_1.pictureBox1.Image = null;
                    zoomPictureBox_16_2.zoomRequired = false;
                    zoomPictureBox_16_2.pictureBox1.Image = null;
                    zoomPictureBox_16_3.zoomRequired = false;
                    zoomPictureBox_16_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "16_1.jpg");
                    File.Delete(PP.gTempFolder + "16_2.jpg");
                    File.Delete(PP.gTempFolder + "16_3.jpg");
                    File.Delete(PP.gTempFolder + "16_1.bmp");
                    File.Delete(PP.gTempFolder + "16_2.bmp");
                    File.Delete(PP.gTempFolder + "16_3.bmp");
                }
                if (I == 16)
                {
                    index[16] = 0;
                    zoomPictureBox_17_1.zoomRequired = false;
                    zoomPictureBox_17_1.pictureBox1.Image = null;
                    zoomPictureBox_17_2.zoomRequired = false;
                    zoomPictureBox_17_2.pictureBox1.Image = null;
                    zoomPictureBox_17_3.zoomRequired = false;
                    zoomPictureBox_17_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "17_1.jpg");
                    File.Delete(PP.gTempFolder + "17_2.jpg");
                    File.Delete(PP.gTempFolder + "17_3.jpg");
                    File.Delete(PP.gTempFolder + "17_1.bmp");
                    File.Delete(PP.gTempFolder + "17_2.bmp");
                    File.Delete(PP.gTempFolder + "17_3.bmp");
                }
                if (I == 17)
                {
                    index[17] = 0;
                    zoomPictureBox_18_1.zoomRequired = false;
                    zoomPictureBox_18_1.pictureBox1.Image = null;
                    zoomPictureBox_18_2.zoomRequired = false;
                    zoomPictureBox_18_2.pictureBox1.Image = null;
                    zoomPictureBox_18_3.zoomRequired = false;
                    zoomPictureBox_18_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "18_1.jpg");
                    File.Delete(PP.gTempFolder + "18_2.jpg");
                    File.Delete(PP.gTempFolder + "18_3.jpg");
                    File.Delete(PP.gTempFolder + "18_1.bmp");
                    File.Delete(PP.gTempFolder + "18_2.bmp");
                    File.Delete(PP.gTempFolder + "18_3.bmp");
                }
                if (I == 18)
                {
                    index[18] = 0;
                    zoomPictureBox_19_1.zoomRequired = false;
                    zoomPictureBox_19_1.pictureBox1.Image = null;
                    zoomPictureBox_19_2.zoomRequired = false;
                    zoomPictureBox_19_2.pictureBox1.Image = null;
                    zoomPictureBox_19_3.zoomRequired = false;
                    zoomPictureBox_19_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "19_1.jpg");
                    File.Delete(PP.gTempFolder + "19_2.jpg");
                    File.Delete(PP.gTempFolder + "19_3.jpg");
                    File.Delete(PP.gTempFolder + "19_1.bmp");
                    File.Delete(PP.gTempFolder + "19_2.bmp");
                    File.Delete(PP.gTempFolder + "19_3.bmp");
                }
                if (I == 19)
                {
                    index[19] = 0;
                    zoomPictureBox_20_1.zoomRequired = false;
                    zoomPictureBox_20_1.pictureBox1.Image = null;
                    zoomPictureBox_20_2.zoomRequired = false;
                    zoomPictureBox_20_2.pictureBox1.Image = null;
                    zoomPictureBox_20_3.zoomRequired = false;
                    zoomPictureBox_20_3.pictureBox1.Image = null;
                    this.textBox_hphm.Text = PP.gDefaultHPHM;
                    File.Delete(PP.gTempFolder + "20_1.jpg");
                    File.Delete(PP.gTempFolder + "20_2.jpg");
                    File.Delete(PP.gTempFolder + "20_3.jpg");
                    File.Delete(PP.gTempFolder + "20_1.bmp");
                    File.Delete(PP.gTempFolder + "20_2.bmp");
                    File.Delete(PP.gTempFolder + "20_3.bmp");
                }

            }
            catch { }
        }

        private void button_save_Click(object sender, EventArgs e)
        {
            try
            {
                //if (this.textBox_hphm.Text.Length <7)
                //{
                //    this.toolStripStatusLabel_state.Text = "保存失败,号牌号码长度不对";
                //    return;
                //}
                if ((I > 19) || (I < 0)) return;

                if ((I == 0) &&
                    ((zoomPictureBox_1_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_1_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_1_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组一违法证据抓拍3张";
                    return;
                }

                if ((I == 1) &&
                    ((zoomPictureBox_2_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_2_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_2_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组二违法证据抓拍3张";
                    return;
                }

                if ((I == 2) &&
                    ((zoomPictureBox_3_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_3_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_3_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 3) &&
                    ((zoomPictureBox_4_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_4_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_4_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 4) &&
                    ((zoomPictureBox_5_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_5_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_5_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 5) &&
                    ((zoomPictureBox_6_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_6_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_6_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 6) &&
                    ((zoomPictureBox_7_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_7_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_7_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 7) &&
                    ((zoomPictureBox_8_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_8_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_8_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 8) &&
                    ((zoomPictureBox_9_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_9_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_9_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 9) &&
                    ((zoomPictureBox_10_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_10_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_10_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 10) &&
                    ((zoomPictureBox_11_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_11_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_11_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 11) &&
                    ((zoomPictureBox_12_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_12_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_12_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 12) &&
                    ((zoomPictureBox_13_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_13_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_13_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 13) &&
                    ((zoomPictureBox_14_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_14_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_14_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 14) &&
                    ((zoomPictureBox_15_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_15_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_15_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 15) &&
                    ((zoomPictureBox_16_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_16_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_16_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 16) &&
                    ((zoomPictureBox_17_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_17_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_17_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 17) &&
                    ((zoomPictureBox_18_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_18_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_18_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 18) &&
                    ((zoomPictureBox_19_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_19_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_19_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }

                if ((I == 19) &&
                    ((zoomPictureBox_20_1.pictureBox1.Image == null) ||
                    (zoomPictureBox_20_2.pictureBox1.Image == null) ||
                    (zoomPictureBox_20_3.pictureBox1.Image == null)))
                {
                    this.toolStripStatusLabel_state.Text = "保存失败,组三违法证据抓拍3张";
                    return;
                }
                if (m_CurrentCam != null)
                {
                    m_CurrentCam.m_WFSJ = this.dateTimePicker1.Value;//m_WFSJ[I];
                    m_CurrentCam.m_HPHM = this.textBox_hphm.Text;
                    string wfxw = this.comboBox_wfxw.Text.Trim();
                    m_CurrentCam.m_WFXWDM = wfxw.Split('-')[0];
                    string hpzl = this.comboBox_hpzl.Text.Trim();
                    m_CurrentCam.m_ManuelHPZL = hpzl.Split('-')[0];
                    m_CurrentCam.m_CDDM = hpzl.Split('-')[0];
                    if (m_CurrentCam.SaveOneGroup((I+1).ToString()) == true)
                    {
                        this.toolStripStatusLabel_state.Text = "保存成功";
                        ZPCLXX zpclxx = new ZPCLXX();
                        zpclxx.Hphm = m_CurrentCam.m_HPHM;
                        zpclxx.Wfdd = m_CurrentCam.m_GBDM;
                        zpclxx.Zpsj = m_CurrentCam.m_WFSJ;
                        zpclxx.Zpr = PP.gUser.username;//m_CurrentCam.m_UserName;
                        zpclxx.Scbj = "0";
                        try
                        {
                            

                            if (new ZPCLXXDAL().Insert(zpclxx) > 0)
                            {
                                LogHelper.WriteLog(typeof(Form_Main), "抓拍信息：" + zpclxx.Hphm + zpclxx.Zpsj + zpclxx.Zpr + "入库成功");

                            }
                            else
                            {
                                LogHelper.WriteLog(typeof(Form_Main), "抓拍信息：" + zpclxx.Hphm + zpclxx.Zpsj + zpclxx.Zpr + "入库");
                            }
                        }
                        catch (System.Exception ex)
                        {
                            LogHelper.WriteLog(typeof(Form_Main), "抓拍信息数据库连接失败,插入" + ex.Message);
                        }

                        button_clear_Click(sender, e);

                        this.dataGridView1.Rows.Add(new object[] 
                        { m_CurrentCam.m_HPHM,
                            m_CurrentCam.m_WFSJ.ToString("yyyy-MM-dd HH:mm:ss"),
                            m_CurrentCam.m_RoadName,
                            m_CurrentCam.m_WFXWDM,
                            m_CurrentCam.m_FileName1,
                            m_CurrentCam.m_FileName2,
                            m_CurrentCam.m_FileName3
                        });
                        m_CurrentCam.m_FileName1 = "";
                        m_CurrentCam.m_FileName2 = "";
                        m_CurrentCam.m_FileName3 = "";
                        m_HPHM[I] = "鄂K";
                    }
                }
            }
            catch { }
        }

        private void panel_play_MouseDown(object sender, MouseEventArgs e)
        {
            pointStart.X = e.X;
            pointStart.Y = e.Y;
            m_FlagRect = true;
        }

        private void panel_play_MouseUp(object sender, MouseEventArgs e)
        {
            pointEnd.X = e.X;
            pointEnd.Y = e.Y;
            if (m_FlagRect == true)
            {
                m_FlagRect = false;
                Rectangle WinRect = new Rectangle(this.panel_play.Location, this.panel_play.Size);
                if (m_CurrentCam != null) m_CurrentCam.PTZ3D(WinRect, pointStart, pointEnd);
            }
        }

        private void panel_play_MouseMove(object sender, MouseEventArgs e)
        {
            Rectangle rt = new Rectangle(this.panel_play.Location, this.panel_play.Size);
            int x = e.X;
            int y = e.Y;
            x = x > rt.Right ? rt.Right : x;
            x = x < rt.Left ? rt.Left : x;
            y = y > rt.Bottom ? rt.Bottom : y;
            y = y < rt.Top ? rt.Top : y;
            pointEnd.X = x;
            pointEnd.Y = y;
        }

        private void zoomPictureBox_1_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[0] = 0;
                zoomPictureBox_1_1.zoomRequired = false;
                zoomPictureBox_1_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "1_1.jpg");
                File.Delete(PP.gTempFolder + "1_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_1_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[0] = 1;
                zoomPictureBox_1_2.zoomRequired = false;
                zoomPictureBox_1_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "1_2.jpg");
                File.Delete(PP.gTempFolder + "1_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_1_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[0] = 2;
                zoomPictureBox_1_3.zoomRequired = false;
                zoomPictureBox_1_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "1_3.jpg");
                File.Delete(PP.gTempFolder + "1_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_2_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[1] = 0;
                zoomPictureBox_2_1.zoomRequired = false;
                zoomPictureBox_2_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "2_1.jpg");
                File.Delete(PP.gTempFolder + "2_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_2_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[1] = 1;
                zoomPictureBox_2_2.zoomRequired = false;
                zoomPictureBox_2_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "2_2.jpg");
                File.Delete(PP.gTempFolder + "2_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_2_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[1] = 2;
                zoomPictureBox_2_3.zoomRequired = false;
                zoomPictureBox_2_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "2_3.jpg");
                File.Delete(PP.gTempFolder + "2_3.bmp");
            }
            catch { }
        }


        private void zoomPictureBox_3_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[2] = 0;
                zoomPictureBox_3_1.zoomRequired = false;
                zoomPictureBox_3_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "3_1.jpg");
                File.Delete(PP.gTempFolder + "3_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_3_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[2] = 1;
                zoomPictureBox_3_2.zoomRequired = false;
                zoomPictureBox_3_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "3_2.jpg");
                File.Delete(PP.gTempFolder + "3_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_3_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[2] = 2;
                zoomPictureBox_3_3.zoomRequired = false;
                zoomPictureBox_3_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "3_3.jpg");
                File.Delete(PP.gTempFolder + "3_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_4_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[3] = 0;
                zoomPictureBox_4_1.zoomRequired = false;
                zoomPictureBox_4_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "4_1.jpg");
                File.Delete(PP.gTempFolder + "4_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_4_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[3] = 1;
                zoomPictureBox_4_2.zoomRequired = false;
                zoomPictureBox_4_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "4_2.jpg");
                File.Delete(PP.gTempFolder + "4_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_4_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[3] = 2;
                zoomPictureBox_4_3.zoomRequired = false;
                zoomPictureBox_4_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "4_3.jpg");
                File.Delete(PP.gTempFolder + "4_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_5_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[4] = 0;
                zoomPictureBox_5_1.zoomRequired = false;
                zoomPictureBox_5_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "5_1.jpg");
                File.Delete(PP.gTempFolder + "5_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_5_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[4] = 1;
                zoomPictureBox_5_2.zoomRequired = false;
                zoomPictureBox_5_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "5_2.jpg");
                File.Delete(PP.gTempFolder + "5_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_5_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[4] = 2;
                zoomPictureBox_5_3.zoomRequired = false;
                zoomPictureBox_5_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "5_3.jpg");
                File.Delete(PP.gTempFolder + "5_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_6_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[5] = 0;
                zoomPictureBox_6_1.zoomRequired = false;
                zoomPictureBox_6_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "6_1.jpg");
                File.Delete(PP.gTempFolder + "6_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_6_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[5] = 1;
                zoomPictureBox_6_2.zoomRequired = false;
                zoomPictureBox_6_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "6_2.jpg");
                File.Delete(PP.gTempFolder + "6_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_6_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[5] = 2;
                zoomPictureBox_6_3.zoomRequired = false;
                zoomPictureBox_6_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "6_3.jpg");
                File.Delete(PP.gTempFolder + "6_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_7_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[6] = 0;
                zoomPictureBox_7_1.zoomRequired = false;
                zoomPictureBox_7_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "7_1.jpg");
                File.Delete(PP.gTempFolder + "7_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_7_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[6] = 1;
                zoomPictureBox_7_2.zoomRequired = false;
                zoomPictureBox_7_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "7_2.jpg");
                File.Delete(PP.gTempFolder + "7_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_7_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[6] = 2;
                zoomPictureBox_7_3.zoomRequired = false;
                zoomPictureBox_7_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "7_3.jpg");
                File.Delete(PP.gTempFolder + "7_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_8_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[7] = 0;
                zoomPictureBox_8_1.zoomRequired = false;
                zoomPictureBox_8_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "8_1.jpg");
                File.Delete(PP.gTempFolder + "8_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_8_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[7] = 1;
                zoomPictureBox_8_2.zoomRequired = false;
                zoomPictureBox_8_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "8_2.jpg");
                File.Delete(PP.gTempFolder + "8_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_8_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[7] = 2;
                zoomPictureBox_8_3.zoomRequired = false;
                zoomPictureBox_8_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "8_3.jpg");
                File.Delete(PP.gTempFolder + "8_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_9_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[8] = 0;
                zoomPictureBox_9_1.zoomRequired = false;
                zoomPictureBox_9_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "9_1.jpg");
                File.Delete(PP.gTempFolder + "9_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_9_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[8] = 1;
                zoomPictureBox_9_2.zoomRequired = false;
                zoomPictureBox_9_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "9_2.jpg");
                File.Delete(PP.gTempFolder + "9_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_9_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[8] = 2;
                zoomPictureBox_9_3.zoomRequired = false;
                zoomPictureBox_9_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "9_3.jpg");
                File.Delete(PP.gTempFolder + "9_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_10_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[9] = 0;
                zoomPictureBox_10_1.zoomRequired = false;
                zoomPictureBox_10_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "10_1.jpg");
                File.Delete(PP.gTempFolder + "10_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_10_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[9] = 1;
                zoomPictureBox_10_2.zoomRequired = false;
                zoomPictureBox_10_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "10_2.jpg");
                File.Delete(PP.gTempFolder + "10_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_10_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[9] = 2;
                zoomPictureBox_10_3.zoomRequired = false;
                zoomPictureBox_10_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "10_3.jpg");
                File.Delete(PP.gTempFolder + "10_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_11_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[10] = 0;
                zoomPictureBox_11_1.zoomRequired = false;
                zoomPictureBox_11_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "11_1.jpg");
                File.Delete(PP.gTempFolder + "11_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_11_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[10] = 1;
                zoomPictureBox_11_2.zoomRequired = false;
                zoomPictureBox_11_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "11_2.jpg");
                File.Delete(PP.gTempFolder + "11_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_11_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[10] = 2;
                zoomPictureBox_11_3.zoomRequired = false;
                zoomPictureBox_11_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "11_3.jpg");
                File.Delete(PP.gTempFolder + "11_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_12_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[11] = 0;
                zoomPictureBox_12_1.zoomRequired = false;
                zoomPictureBox_12_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "12_1.jpg");
                File.Delete(PP.gTempFolder + "12_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_12_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[11] = 1;
                zoomPictureBox_12_2.zoomRequired = false;
                zoomPictureBox_12_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "12_2.jpg");
                File.Delete(PP.gTempFolder + "12_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_12_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[11] = 2;
                zoomPictureBox_12_3.zoomRequired = false;
                zoomPictureBox_12_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "12_3.jpg");
                File.Delete(PP.gTempFolder + "12_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_13_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[12] = 0;
                zoomPictureBox_13_1.zoomRequired = false;
                zoomPictureBox_13_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "13_1.jpg");
                File.Delete(PP.gTempFolder + "13_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_13_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[12] = 1;
                zoomPictureBox_13_2.zoomRequired = false;
                zoomPictureBox_13_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "13_2.jpg");
                File.Delete(PP.gTempFolder + "13_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_13_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[12] = 2;
                zoomPictureBox_13_3.zoomRequired = false;
                zoomPictureBox_13_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "13_3.jpg");
                File.Delete(PP.gTempFolder + "13_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_14_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[13] = 0;
                zoomPictureBox_14_1.zoomRequired = false;
                zoomPictureBox_14_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "14_1.jpg");
                File.Delete(PP.gTempFolder + "14_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_14_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[13] = 1;
                zoomPictureBox_14_2.zoomRequired = false;
                zoomPictureBox_14_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "14_2.jpg");
                File.Delete(PP.gTempFolder + "5_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_14_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[13] = 2;
                zoomPictureBox_14_3.zoomRequired = false;
                zoomPictureBox_14_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "14_3.jpg");
                File.Delete(PP.gTempFolder + "14_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_15_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[14] = 0;
                zoomPictureBox_15_1.zoomRequired = false;
                zoomPictureBox_15_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "15_1.jpg");
                File.Delete(PP.gTempFolder + "15_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_15_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[14] = 1;
                zoomPictureBox_15_2.zoomRequired = false;
                zoomPictureBox_15_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "15_2.jpg");
                File.Delete(PP.gTempFolder + "15_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_15_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[14] = 2;
                zoomPictureBox_15_3.zoomRequired = false;
                zoomPictureBox_15_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "15_3.jpg");
                File.Delete(PP.gTempFolder + "15_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_16_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[15] = 0;
                zoomPictureBox_16_1.zoomRequired = false;
                zoomPictureBox_16_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "16_1.jpg");
                File.Delete(PP.gTempFolder + "16_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_16_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[15] = 1;
                zoomPictureBox_16_2.zoomRequired = false;
                zoomPictureBox_16_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "16_2.jpg");
                File.Delete(PP.gTempFolder + "16_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_16_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[15] = 2;
                zoomPictureBox_16_3.zoomRequired = false;
                zoomPictureBox_16_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "16_3.jpg");
                File.Delete(PP.gTempFolder + "16_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_17_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[16] = 0;
                zoomPictureBox_17_1.zoomRequired = false;
                zoomPictureBox_17_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "17_1.jpg");
                File.Delete(PP.gTempFolder + "17_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_17_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[16] = 1;
                zoomPictureBox_17_2.zoomRequired = false;
                zoomPictureBox_17_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "17_2.jpg");
                File.Delete(PP.gTempFolder + "17_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_17_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[16] = 2;
                zoomPictureBox_17_3.zoomRequired = false;
                zoomPictureBox_17_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "17_3.jpg");
                File.Delete(PP.gTempFolder + "17_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_18_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[17] = 0;
                zoomPictureBox_18_1.zoomRequired = false;
                zoomPictureBox_18_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "18_1.jpg");
                File.Delete(PP.gTempFolder + "18_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_18_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[17] = 1;
                zoomPictureBox_18_2.zoomRequired = false;
                zoomPictureBox_18_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "18_2.jpg");
                File.Delete(PP.gTempFolder + "18_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_18_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[17] = 2;
                zoomPictureBox_18_3.zoomRequired = false;
                zoomPictureBox_18_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "18_3.jpg");
                File.Delete(PP.gTempFolder + "18_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_19_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[18] = 0;
                zoomPictureBox_19_1.zoomRequired = false;
                zoomPictureBox_19_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "19_1.jpg");
                File.Delete(PP.gTempFolder + "19_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_19_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[18] = 1;
                zoomPictureBox_19_2.zoomRequired = false;
                zoomPictureBox_19_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "19_2.jpg");
                File.Delete(PP.gTempFolder + "19_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_19_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[18] = 2;
                zoomPictureBox_19_3.zoomRequired = false;
                zoomPictureBox_19_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "19_3.jpg");
                File.Delete(PP.gTempFolder + "19_3.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_20_1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[19] = 0;
                zoomPictureBox_20_1.zoomRequired = false;
                zoomPictureBox_20_1.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "20_1.jpg");
                File.Delete(PP.gTempFolder + "20_1.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_20_2_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[19] = 1;
                zoomPictureBox_20_2.zoomRequired = false;
                zoomPictureBox_20_2.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "20_2.jpg");
                File.Delete(PP.gTempFolder + "20_2.bmp");
            }
            catch { }
        }

        private void zoomPictureBox_20_3_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                index[19] = 2;
                zoomPictureBox_20_3.zoomRequired = false;
                zoomPictureBox_20_3.pictureBox1.Image = null;
                File.Delete(PP.gTempFolder + "20_3.jpg");
                File.Delete(PP.gTempFolder + "20_3.bmp");
            }
            catch { }
        }

        //键盘处理
        private void Form_Main_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = false;
        }

        private void Form_Main_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                switch (e.KeyValue)
                {
                    case 49:
                        if (e.Control) tabControl2.SelectedIndex = 0;
                        break;
                    case 50:
                        if (e.Control) tabControl2.SelectedIndex = 1;
                        break;
                    case 51:
                        if (e.Control) tabControl2.SelectedIndex = 2;
                        break;
                    case 52:
                        if (e.Control) tabControl2.SelectedIndex = 3;
                        break;
                    case 53:
                        if (e.Control) tabControl2.SelectedIndex = 4;
                        break;
                    case 54:
                        if (e.Control) tabControl2.SelectedIndex = 5;
                        break;
                    case 38://上
                        button_up_MouseDown(null, null);
                        e.Handled = true;
                        break;
                    case 40://下
                        button_down_MouseDown(null, null);
                        e.Handled = true;
                        break;
                    case 37://左
                        button_left_MouseDown(null, null);
                        e.Handled = true;
                        break;
                    case 39://右
                        button_right_MouseDown(null, null);
                        e.Handled = true;
                        break;
                    case 186://拉近
                        button_near_MouseDown(null, null);
                        e.Handled = true;
                        break;
                    case 222://拉远
                        button_far_MouseDown(null, null);
                        e.Handled = true;
                        break;
                    case 187://速度+
                        button_speedup_Click(null, null);
                        e.Handled = true;
                        break;
                    case 189://速度-
                        button_speeddown_Click(null, null);
                        e.Handled = true;
                        break;
                    case 32://抓怕
                        button_capture_Click(null, null);
                        e.Handled = true;
                        break;
                    //case 13://保存
                    //    button_save_Click(null, null);
                    //    e.Handled = true;
                    //    break;
                    case 188://重拍1
                        if (I == 0)
                        {
                            index[0] = 0;
                            zoomPictureBox_1_1.zoomRequired = false;
                            zoomPictureBox_1_1.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "1_1.jpg");
                            File.Delete(PP.gTempFolder + "1_1.bmp");
                        }
                        if (I == 1)
                        {
                            index[1] = 0;
                            zoomPictureBox_2_1.zoomRequired = false;
                            zoomPictureBox_2_1.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "2_1.jpg");
                            File.Delete(PP.gTempFolder + "2_1.bmp");
                        }
                        if (I == 2)
                        {
                            index[2] = 0;
                            zoomPictureBox_3_1.zoomRequired = false;
                            zoomPictureBox_3_1.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "3_1.jpg");
                            File.Delete(PP.gTempFolder + "3_1.bmp");
                        }
                        if (I == 3)
                        {
                            index[3] = 0;
                            zoomPictureBox_4_1.zoomRequired = false;
                            zoomPictureBox_4_1.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "4_1.jpg");
                            File.Delete(PP.gTempFolder + "4_1.bmp");
                        }
                        if (I == 4)
                        {
                            index[4] = 0;
                            zoomPictureBox_5_1.zoomRequired = false;
                            zoomPictureBox_5_1.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "5_1.jpg");
                            File.Delete(PP.gTempFolder + "5_1.bmp");
                        }
                        e.Handled = true;
                        break;
                    case 190://重拍2
                        if (I == 0)
                        {
                            index[0] = 1;
                            zoomPictureBox_1_2.zoomRequired = false;
                            zoomPictureBox_1_2.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "1_2.jpg");
                            File.Delete(PP.gTempFolder + "1_2.bmp");
                        }
                        if (I == 1)
                        {
                            index[1] = 1;
                            zoomPictureBox_2_2.zoomRequired = false;
                            zoomPictureBox_2_2.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "2_2.jpg");
                            File.Delete(PP.gTempFolder + "2_2.bmp");
                        }
                        if (I == 2)
                        {
                            index[2] = 1;
                            zoomPictureBox_3_2.zoomRequired = false;
                            zoomPictureBox_3_2.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "3_2.jpg");
                            File.Delete(PP.gTempFolder + "3_2.bmp");
                        }
                        if (I == 3)
                        {
                            index[3] = 1;
                            zoomPictureBox_4_2.zoomRequired = false;
                            zoomPictureBox_4_2.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "4_2.jpg");
                            File.Delete(PP.gTempFolder + "4_2.bmp");
                        }
                        if (I == 4)
                        {
                            index[4] = 1;
                            zoomPictureBox_5_2.zoomRequired = false;
                            zoomPictureBox_5_2.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "5_2.jpg");
                            File.Delete(PP.gTempFolder + "5_2.bmp");
                        }
                        e.Handled = true;
                        break;
                    case 191://重拍3
                        if (I == 0)
                        {
                            index[0] = 2;
                            zoomPictureBox_1_3.zoomRequired = false;
                            zoomPictureBox_1_3.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "1_3.jpg");
                            File.Delete(PP.gTempFolder + "1_3.bmp");
                        }
                        if (I == 1)
                        {
                            index[1] = 2;
                            zoomPictureBox_2_3.zoomRequired = false;
                            zoomPictureBox_2_3.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "2_3.jpg");
                            File.Delete(PP.gTempFolder + "2_3.bmp");
                        }
                        if (I == 2)
                        {
                            index[2] = 2;
                            zoomPictureBox_3_3.zoomRequired = false;
                            zoomPictureBox_3_3.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "3_3.jpg");
                            File.Delete(PP.gTempFolder + "3_3.bmp");
                        }
                        if (I == 3)
                        {
                            index[3] = 2;
                            zoomPictureBox_4_3.zoomRequired = false;
                            zoomPictureBox_4_3.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "4_3.jpg");
                            File.Delete(PP.gTempFolder + "4_3.bmp");
                        }
                        if (I == 4)
                        {
                            index[4] = 2;
                            zoomPictureBox_5_3.zoomRequired = false;
                            zoomPictureBox_5_3.pictureBox1.Image = null;
                            File.Delete(PP.gTempFolder + "5_3.jpg");
                            File.Delete(PP.gTempFolder + "5_3.bmp");
                        }
                        e.Handled = true;
                        break;
                    case 112:
                    case 113:
                    case 114:
                    case 115:
                    case 116:
                    case 117:
                    case 118:
                    case 119:
                    case 120:
                    case 121:
                        if (m_CurrentCam != null) m_CurrentCam.CallPreSetPoint(e.KeyValue - 111);
                        e.Handled = true;
                        break;
                    default:
                        e.Handled = false;
                        break;
                }
            }
            catch { }
        }

        private void Form_Main_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                switch (e.KeyValue)
                {
                    case 38://上
                        button_up_MouseUp(null, null);
                        e.Handled = true;
                        break;
                    case 40://下
                        button_down_MouseUp(null, null);
                        e.Handled = true;
                        break;
                    case 37://左
                        button_left_MouseUp(null, null);
                        e.Handled = true;
                        break;
                    case 39://右
                        button_right_MouseUp(null, null);
                        e.Handled = true;
                        break;
                    case 186://拉近
                        button_near_MouseUp(null, null);
                        e.Handled = true;
                        break;
                    case 222://拉远
                        button_far_MouseUp(null, null);
                        e.Handled = true;
                        break;
                    default:
                        e.Handled = false;
                        break;
                }
            }
            catch { }
        }

        private void ToolStripMenuItem_upload_Click(object sender, EventArgs e)
        {
            UploadForm form = new UploadForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void toolStripMenuItem_changepassword_Click(object sender, EventArgs e)
        {
            ChangeForm cf = new ChangeForm();
            cf.Owner = this;
            cf.ShowDialog();
            cf.Dispose();
        }

        private void toolStripMenuItem_yhgl_Click(object sender, EventArgs e)
        {
            UserForm form = new UserForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void toolStripMenuItem_wfxwdm_Click(object sender, EventArgs e)
        {
            WFXWDMForm form = new WFXWDMForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void ToolStripMenuItem_hpzl_Click(object sender, EventArgs e)
        {
            HPZLForm form = new HPZLForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void tabControl2_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (tabControl2.SelectedIndex < 0) return;
                if (tabControl2.SelectedIndex < 20)
                {
                    I = tabControl2.SelectedIndex;
                    this.dateTimePicker1.Value = m_WFSJ[I];
                    this.textBox_hphm.Text = m_HPHM[I];
                    tabControl1.SelectedIndex = 0;
                }
                if (tabControl2.SelectedIndex == 20)
                {
                    tabControl1.SelectedIndex = 1;
                }
            }
            catch { }
        }

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex < 0) return;
            if (tabControl1.SelectedIndex == 0) tabControl2.SelectedIndex = I;
            if (tabControl1.SelectedIndex == 1) tabControl2.SelectedIndex = 20;
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (this.dataGridView1.SelectedRows.Count >= 1)
                {
                    string path1 = this.dataGridView1.SelectedRows[0].Cells["path1"].Value.ToString();
                    string path2 = this.dataGridView1.SelectedRows[0].Cells["path2"].Value.ToString();
                    string path3 = this.dataGridView1.SelectedRows[0].Cells["path3"].Value.ToString();
                    if (File.Exists(path1)) zoomPictureBox_his_1.pictureBox1.LoadAsync(path1);
                    if (File.Exists(path2)) zoomPictureBox_his_2.pictureBox1.LoadAsync(path2);
                    if (File.Exists(path3)) zoomPictureBox_his_3.pictureBox1.LoadAsync(path3);
                }
            }
            catch { }
        }

        private void splitContainer1_DoubleClick(object sender, EventArgs e)
        {
            if (this.splitContainer1.SplitterDistance <= 100)
            {
                this.splitContainer1.SplitterDistance = SplitterDistance2;
                return;
            }

            if (this.splitContainer1.SplitterDistance > 100)
            {
                this.splitContainer1.SplitterDistance = SplitterDistance1;
                return;
            }
        }

        private void ToolStripMenuItem_tongji1_Click(object sender, EventArgs e)
        {
            TongJiForm form = new TongJiForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void ToolStripMenuItem_tongji2_Click(object sender, EventArgs e)
        {
            WorkTongJiForm form = new WorkTongJiForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void toolStripMenuItem_bumen_Click(object sender, EventArgs e)
        {
            BuMenForm form = new BuMenForm();
            form.Owner = this;
            form.ShowDialog();
            form.Dispose();
        }

        private void button_sendSMS_Click(object sender, EventArgs e)
        {            
            //发短信
            string sendText = "【孝感交警】" + textBox_hphm.Text + "车主您好，您的车辆"
                            + TimeHelper.FormatDate(DateTime.Now, "10")
                            + "在" + m_CurrentCam.m_CameraName
                            + "违章停车，请在5分钟内驶离，否则将拍摄取证";
            WebReferenceNew.SmsSend client = new WebReferenceNew.SmsSend();

            int nrst = -1;//调用结果，返回的数字代表当前缓冲队列短信数。
            bool brst = false;

            client.AddSmsData(textBox_SMS.Text, sendText, out nrst, out brst);

            bool bresult = false;//返回值，代表是否成功
            bool brst2 = false;
            client.SendSignal(out bresult, out brst2);

            //打电话
            //INSERT INTO SendQueue
            //       (Phonenum1, Vsource, sendtype, maxtimes, timing, Taskid, Vmode, Stimes, State, Priority)

            //VALUES
            //      ('18601504926', '[s4]你好啊', '0', '1', '0', '-1', '1', '0', '0', '2')
            SendQueue sendqueue = new SendQueue();
            sendqueue.Phonenum1 = textBox_SMS.Text;
            sendqueue.Vsource = sendText;
            sendqueue.Sendtype = 0;
            sendqueue.Maxtimes = 1;
            sendqueue.Timing = 0;
            sendqueue.Taskid = -1;
            sendqueue.Vmode = 1;
            sendqueue.Stimes = 0;
            sendqueue.State = 0;
            sendqueue.Priority = 2;
            new SendQueueDAL().Insert(sendqueue);
            textBox_SMS.Text = "";


        }

        private void textBox_hphm_MouseLeave(object sender, EventArgs e)
        {



        }

        public bool IsStandardCarNum(string strCarNum)
        {
            //车牌正则表达式
            Regex rx = new Regex(@"^[\u4e00-\u9fa5]{1}[a-zA-Z]{1}[a-zA-Z_0-9]{4}[a-zA-Z_0-9_\u4e00-\u9fa5]$|^[a-zA-Z]{2}\d{7}$");
            if (!rx.IsMatch(strCarNum))
            {
                return false;
            }

            return true;
        }

        private void textBox_hphm_Leave(object sender, EventArgs e)
        {

            string hpzl = (comboBox_hpzl.Text).Substring(0,2);
            string hphm = textBox_hphm.Text;
            if ((hphm != ""))
            {
                //string YZhphm = hphm.Substring(hphm.Length - 5);
                //if (IsStandardCarNum(YZhphm))
                //{
                //    textBox_SMS.Text = new VEHDAL().GetById(hphm);

                //}
                if (hphm.Length >= 6)
                {
                    string ReturnCLXXValue = null;
                    string ReturnValue = null;
                    try
                    {
                        //ReturnCLXXValue = new ZPCLXXDAL().GetById(hphm,m_CurrentCam.m_GBDM, TimeHelper.FormatDate(DateTime.Now, "0"));
                        ReturnCLXXValue = new ZPCLXXDAL().GetById(hphm, m_CurrentCam.m_GBDM, TimeHelper.FormatDate(DateTime.Now, "0"));
                    }
                    catch (System.Exception ex)
                    {
                        //MessageBox.Show("先开启监控图像后再输入号牌信息，如已开启请联系管理员");
                        LogHelper.WriteLog(typeof(Form_Main), "重复抓拍" + ex.Message);

                    }
                    if (ReturnCLXXValue != null)
                    {
                        string nowTime = TimeHelper.FormatDate(DateTime.Now, "0");
                        string zpTime = TimeHelper.FormatDate(Convert.ToDateTime(ReturnCLXXValue), "0");
                        if (zpTime == nowTime)
                        {
                            MessageBox.Show("重复抓拍车辆");
                            LogHelper.WriteLog(typeof(Form_Main), hphm + "--重复抓拍已提醒，抓拍人是：" + PP.gUser.username + "，抓拍时间是：" + ReturnCLXXValue + "，抓拍地点是：" + m_CurrentCam.m_GBDM);
                        }
                    }
                    else
                    {
                        try
                        {
	                        textBox_SMS.Text = new VEHDAL().GetById(hphm.Substring(hphm.Length - 6),hpzl);
	                        ReturnValue = new BLACKDAL().GetById(hphm);
                        }
                        catch (System.Exception ex)
                        {
                            //MessageBox.Show("车管所数据库连接失败，请联系管理员");
                            LogHelper.WriteLog(typeof(Form_Main), "车管所数据库" + ex.Message);

                        }

                        if (ReturnValue != null)
                        {
                            switch (ReturnValue)
                            {
                                case "1"://上
                                    MessageBox.Show("嫌疑套牌车辆");
                                    break;
                                case "2"://下
                                    MessageBox.Show("查无信息车辆");
                                    break;
                            }

                        }

                    }


                }
            }
            else
            {
                MessageBox.Show("车牌号不能为空");
            }

        }

        private void button_雨刷_Click(object sender, EventArgs e)
        {

        }

        private void button_雨刷_MouseDown(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Yushua(speed, false);

        }

        private void button_雨刷_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_CurrentCam != null) m_CurrentCam.Yushua(speed, true);

        }

        private void button_phone_Click(object sender, EventArgs e)
        {
            //发短信
            string sendText = "【孝感交警】" + textBox_hphm.Text + "车主您好，您的车辆"
                            + TimeHelper.FormatDate(DateTime.Now, "10")
                            + "在" + m_CurrentCam.m_CameraName
                            + "违章停车，请在5分钟内驶离，否则将拍摄取证";
            WebReferenceNew.SmsSend client = new WebReferenceNew.SmsSend();

            int nrst = -1;//调用结果，返回的数字代表当前缓冲队列短信数。
            bool brst = false;

            client.AddSmsData(textBox_SMS.Text, sendText, out nrst, out brst);

            bool bresult = false;//返回值，代表是否成功
            bool brst2 = false;
            client.SendSignal(out bresult, out brst2);
            textBox_SMS.Text = "";

        }
    }
}
